<template>
  <div class="shangpinDialog">
    <el-dialog
      title="选择采购单"
      :close-on-click-modal="false"
      :visible.sync="dialogTableVisible"
      width="500">
      <div class="pageTop">
        <el-form :model="queryParams" ref="queryParams" :inline="true" class="inputWidth"  style="padding: 0px 10px; padding-top: 20px;" >
          <el-form-item label="" >
            <el-input
              style="width: 250px"
              v-model="queryParams.code"
              placeholder="请输入商品编号或名称或型号"
              clearable
              size="medium"
            />
          </el-form-item>
          <el-form-item label="" >
            <el-button type="primary" size="medium" @click="getList">搜 索</el-button>
          </el-form-item>

        </el-form>
      </div>
      <el-table
        highlight-current-row
        max-height="300"
        @row-click="rowClick"
        v-loading="loading"
        :data="dataList"
        stripe border style="margin-top: 20px"
        :header-cell-style="{background:'#eef1f6',color:'#606266'}">
        <el-table-column  width="35">
          <template slot-scope="scope">
            <el-radio :label="scope.row.code" v-model="radioId">&nbsp;</el-radio>
          </template>
        </el-table-column>
        <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
        <el-table-column align="center" label="编号"   property="code"   ></el-table-column>
        <el-table-column align="center" label="名称"   property="name"   ></el-table-column>
        <el-table-column align="center" label="联系人"   property="ren"   ></el-table-column>
        <el-table-column align="center" label="手机"   property="shouji"   ></el-table-column>
      </el-table>
      <el-pagination
        style="margin-top: 20px;text-align: right"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30, 40]"
        :current-page="queryParams.pageNum"
        :page-size="queryParams.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="40">
      </el-pagination>


      <div class="pageTop" style="padding:10px;margin-top: 15px;text-align: right">
        <el-button type="primary" size="medium" @click="determine" >确 定</el-button>
        <el-button  size="medium" @click="cancel" >关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  props: ['cgdData'],
  name: "Role",
  data() {
    return {
      radioId:'',
      ckname:'',
      loading:false,
      dataList:[
        {ckname:'仓库1',code:'CG202011021833047',name:'采购单1',ren:'张三',shouji:'15162063948',id:'1'},
        {ckname:'仓库2',code:'CG202011021833048',name:'采购单2',ren:'张三2',shouji:'15162063948',id:'2'},
        {ckname:'仓库3',code:'CG202011021833049',name:'采购单3',ren:'张三3',shouji:'15162063948',id:'3'},
        {ckname:'仓库4',code:'CG202011021833050',name:'采购单4',ren:'张三4',shouji:'15162063948',id:'4'},
        {ckname:'仓库5',code:'CG202011021833051',name:'采购单5',ren:'张三5',shouji:'15162063948',id:'5'},
      ],
      dialogTableVisible:true,
      queryParams:{
        pageNum:1,
        pageSize:10,
        deptId:'',
      },
      multipleSelection:[],
    };
  },
  watch: {
    dialogTableVisible: function () {
      this.dialogTableVisible = true;//始终让他为true;
      this.cancel();//隐藏
    },
  },
  created() {
    console.log('接受',this.cgdData)


  },
  mounted() {

  },
  methods: {
    rowClick(row){
      this.radioId=row.code;
      this.ckname = row.ckname
      console.log('单选',this.radioId)
    },
    //分页查询
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.queryParams.pageNum = val
      this.getList()
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.queryParams.pageSize = val
      this.getList()
    },
    //搜索
    getList:function (){
      console.log('搜一下')

    },
    //确定
    determine:function(){
      var obj={}
      obj.ckname =  this.ckname
      obj.radioId =  this.radioId
      this.$emit('callback',obj)//将submitModel的值传给父组件
    },
    //隐藏
    cancel:function(){
      // this.determine()
      this.$emit('callback','')//将submitModel的值传给父组件
    },

  }
};
</script>
<style scoped>
.shangpinDialog {

}



</style>
